url = 'https://www.acwing.com/problem/content/790/'

def merge_sort(q, l, r):
    if l >= r:
        return 0

    mid = (l + r) >> 1

    res = merge_sort(q, l, mid) + merge_sort(q, mid + 1, r)

    k = i = l
    j = mid + 1
    while i <= mid and j <= r:
        if q[i] <= q[j]:
            tmp[k] = q[i]
            i += 1
        else:
            res += mid - i + 1
            tmp[k] = q[j]
            j += 1
        k += 1

    while i <= mid:
        tmp[k] = q[i]
        i += 1
        k += 1
    while j <= r:
        tmp[k] = q[j]
        j += 1
        k += 1

    for i in range(l, r + 1):
        q[i] = tmp[i]

    return res

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

    tmp = [0] * n
    print(merge_sort(a, 0, n - 1))
